home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / winsnap.z / winsnap
Text File  |  2002-10-15  |  1KB  |  74 lines

  1. #!/bin/sh
  2.  
  3.  
  4. # test for correct usage
  5. #########################################
  6.  
  7. if [ $# -gt 1 ]
  8. then
  9.     echo "usage: `basename $0` [filename]"
  10.     exit 1
  11. fi
  12.  
  13.  
  14. # check for optional arg
  15. #########################################
  16.  
  17. if [ $# -eq 1 ]
  18. then
  19.     outfile="$1"
  20. else
  21.     outfile="winsnap.rgb"
  22. fi
  23.  
  24.  
  25.  
  26. # select the desired window
  27. #########################################
  28.  
  29.  
  30. echo "`basename $0`: Please select the window you would like to snapshot"
  31. echo "    by clicking the mouse in that window"
  32.  
  33. win=`xwininfo | grep 'Corners:' | tr '+-' '  '`
  34.  
  35. ### echo "$win"
  36.  
  37. x1=`echo "$win" | awk '{print $2}'`
  38. x2=`echo "$win" | awk '{print $6}'`
  39. y1=`echo "$win" | awk '{print $3}'`
  40. y2=`echo "$win" | awk '{print $7}'`
  41.  
  42. ### echo $x1,$y1 $x2,$y2
  43.  
  44.  
  45.  
  46. # get root window info to find out the screen size
  47. ########################################################
  48.  
  49. root=`xwininfo -root`
  50.  
  51. xsize=`echo "$root" | grep 'Width:' | awk '{print $2}'`
  52. ysize=`echo "$root" | grep 'Height:' | awk '{print $2}'`
  53.  
  54. ### echo $xsize, $ysize
  55.  
  56.  
  57.  
  58. # find GL coordinates of the desired window
  59. ####################################################
  60.  
  61. x1gl=$x1
  62. x2gl=`expr $xsize - $x2 - 1`
  63.  
  64. y1gl=$y2
  65. y2gl=`expr $ysize - $y1 - 1`
  66.  
  67. ### echo "scrsave $outfile $x1gl $x2gl $y1gl $y2gl"
  68.  
  69.  
  70. # do the snapshot
  71. #######################
  72.  
  73. scrsave "$outfile" $x1gl $x2gl $y1gl $y2gl
  74.